package com.ruoyi.archive.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.archive.domain.SMainAppeal;
import com.ruoyi.archive.service.ISMainAppealService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 主要诉求模块Controller
 * 
 * @author Allen
 * @date 2021-09-30
 */
@RestController
@RequestMapping("/archive_info/main_appeal")
public class SMainAppealController extends BaseController
{
    @Autowired
    private ISMainAppealService sMainAppealService;

    /**
     * 查询主要诉求模块列表
     */
    @PreAuthorize("@ss.hasPermi('archive_info:main_appeal:list')")
    @GetMapping("/list")
    public TableDataInfo list(SMainAppeal sMainAppeal)
    {
        startPage();
        List<SMainAppeal> list = sMainAppealService.selectSMainAppealList(sMainAppeal);
        return getDataTable(list);
    }

    /**
     * 导出主要诉求模块列表
     */
    @PreAuthorize("@ss.hasPermi('archive_info:main_appeal:export')")
    @Log(title = "主要诉求模块", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SMainAppeal sMainAppeal)
    {
        List<SMainAppeal> list = sMainAppealService.selectSMainAppealList(sMainAppeal);
        ExcelUtil<SMainAppeal> util = new ExcelUtil<SMainAppeal>(SMainAppeal.class);
        return util.exportExcel(list, "主要诉求模块数据");
    }

    /**
     * 获取主要诉求模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive_info:main_appeal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sMainAppealService.selectSMainAppealById(id));
    }

    /**
     * 新增主要诉求模块
     */
    @PreAuthorize("@ss.hasPermi('archive_info:main_appeal:add')")
    @Log(title = "主要诉求模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SMainAppeal sMainAppeal)
    {
        return toAjax(sMainAppealService.insertSMainAppeal(sMainAppeal));
    }

    /**
     * 修改主要诉求模块
     */
    @PreAuthorize("@ss.hasPermi('archive_info:main_appeal:edit')")
    @Log(title = "主要诉求模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SMainAppeal sMainAppeal)
    {
        return toAjax(sMainAppealService.updateSMainAppeal(sMainAppeal));
    }

    /**
     * 删除主要诉求模块
     */
    @PreAuthorize("@ss.hasPermi('archive_info:main_appeal:remove')")
    @Log(title = "主要诉求模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sMainAppealService.deleteSMainAppealByIds(ids));
    }
}
